<%@page contentType="text/html" language="java" import="com.compuvest.web.*,java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ taglib uri="/WEB-INF/tld/navigation.tld" prefix="navigation" %>
<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>
<%@ taglib uri="/WEB-INF/tld/bottom.tld" prefix="bottom" %>

<jsp:useBean id="sb" class="MySQL" scope="application"/>
<jsp:useBean id="advertArray" class="AdvertArray" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%!
    private static final String dotline = "<div class=tfi2>..........................................................................</div>";

    public String selectExtWarranty(int pos, double warrantyPrice1, double warrantyPrice2, double warrantyPrice3, String desc) {
	double price = 0d;
	switch(pos) {
	    case 1  : price = warrantyPrice1; break;
	    case 2  : price = warrantyPrice2; break;
	    case 3  : price = warrantyPrice3; break;
	    default : price = 0d;
	}
	return price == 0d ? "" : String.format("<br/> + %s $%(,.2f", desc, price);
    }
%>
<%
    String thisURL = "Descr.jsp";

    java.text.DecimalFormat priceForm = new java.text.DecimalFormat("$#,##0.00");

    int itemID = advertArray.getInt(request.getParameter("iid"), 0);

    // if from advert
    String accwareCode = request.getParameter("acc");

    Items items = sb.getItem(itemID, accwareCode, basket.getClickstream().getAdvertSite());
    Item item = new Item();
    if(items.size() != 0) {
		item = items.getItems().get(0); // select first item
    }

    session.setAttribute("backItemsPage", thisURL + "?iid=" + itemID);
%>
<html>
<%@include file="/incl/head.html" %>

<body onload="mk_act(1,<%= itemID %>);">

<table style='height:100%;'>

<tr height=100>
 <td>

<head:show />

 </td>
</tr>

<tr>
 <td align=center valign=top>

<navigation:show
 categoryID='<%= item.getCategoryParent() %>'
 subcategoryID='<%= item.getCategoryID() %>'
 lowPrice='0'
 hiPrice='0'
 items='<%= items %>'
 popUrl=''
 />

<fieldset style='width:97%;' class='labl'><%= item.getItemName() %></fieldset>
<br/>
<fieldset style='width:97%;'>
 <table cellspacing=6>
  <tr>
   <td align=center><p><img onError='hideErr(this);' src='<%= application.getInitParameter("imgb") %><%= item.getAccwareCode() %>.jpg' alt=""/></p>
   <a class='exc' href='<%= application.getInitParameter("http") + "Basket.jsp" %>?iidd=<%= item.getItemID() %>'>Add Item to Cart</a>
   </td>
   <td width='5%'>&nbsp;</td>
   <td>
<%    if(item.getMfrLink() != null && item.getMfrLink().length() != 0) { %>
    <div style='font:bold 9pt Arial;'><a href='http://<%= item.getMfrLink() %>' target=_blank>Product details at manufacturer's site</a></div><br/>
<%    } %>
    <div class='mess2'>
<%
    if(item.getResPrice1() != 0d) {
	StringBuilder rline = new StringBuilder(600);

        rline.append("<div class=prel><div class=tfi2>&nbsp;</div>");
        rline.append("<div class='absleft tfi2 onw'>Your Price:</div>");
        rline.append("<div class='absright tfi2 onw'>&nbsp;</div>");
        rline.append("</div>");

	if(item.getResPrice1() != 0d) {
    	    rline.append("<div class=prel>").append(dotline);
    	    rline.append("<div class='absleft tfi4 onw'>1+</div>");
    	    rline.append("<div class='absright tfi4 onw'>").append(priceForm.format(item.getResPrice1())).append("</div>");
    	    rline.append("</div>");
	}
	if(item.getResQuantity2() != 0 && item.getResPrice2() != 0d) {
    	    rline.append("<div class=prel>").append(dotline);
    	    rline.append("<div class='absleft tfi4 onw'>").append(item.getResQuantity2() + 1).append("+</div>");
    	    rline.append("<div class='absright tfi4 onw'>").append(priceForm.format(item.getResPrice2())).append("</div>");
    	    rline.append("</div>");
	}
	if(item.getResQuantity3() != 0 && item.getResPrice3() != 0d) {
    	    rline.append("<div class=prel>").append(dotline);
    	    rline.append("<div class='absleft tfi4 onw'>").append(item.getResQuantity3() + 1).append("+</div>");
    	    rline.append("<div class='absright tfi4 onw'>").append(priceForm.format(item.getResPrice3())).append("</div>");
    	    rline.append("</div>");
	}
        rline.append("<div class=prel>").append(dotline);
        rline.append("<div class='absleft tfi2 onw'>&nbsp;</div>");
        rline.append("<div class='absright tfi2 onw'>&nbsp;</div>");
        rline.append("</div>");

	out.write(rline.toString());
    }
%>
     <div class=prel><%= dotline %>
      <div class='absleft tfi2 onw' style='color:red;'><%= items.getPriceMessage(item.getBannerMask(), true) %>:</div>
      <div class='absright tfi2 onw' style='color:red;'><%= priceForm.format(item.getPrice()) %></div>
     </div>
     <div class=prel><%= dotline %>
      <div class='absleft tfi2 onw'>Manufacturer:</div>
      <div class='absright tfi2 onw'><%= item.getMfrName() %></div>
     </div>

     <div class=prel><%= dotline %>
      <div class='absleft tfi2 onw'>Manufacturer P/N:</div>
      <div class='absright tfi2 onw'><%= item.getMfrNumber() %></div>
     </div>
     <div class=prel><%= dotline %>
      <div class='absleft tfi2 onw'>CompuVest P/N:</div>
      <div class='absright tfi2 onw'><%= item.getAccwareCode() %></div>
     </div>
     <div class=curhand onclick="location.href='<%= application.getInitParameter("info") + "BeforeOrdering.jsp#c2" %>'">
      <div class=prel><%= dotline %>
       <div class='absleft tfi2 onw'>Condition:</div>
       <div class='absright tfi2 onw' style='color:blue;text-decoration:underline;'><%= item.getCondition() %></div>
      </div>
      <div class=prel><%= dotline %>
       <div class='absleft tfi2 onw'>Package:</div>
       <div class='absright tfi2 onw' style='color:blue;text-decoration:underline;'><%= item.getPackage() %></div>
      </div>
     </div>
     <div class=prel><%= dotline %>
      <div class='absleft tfi2 onw'>Stock:</div>
      <div class='absright tfi2 onw'><%= item.getStock() ? "Yes" : Integer.toString(item.getQuantity()) %></div>
     </div>
<% // comming-soon or ships in
    if((item.getBannerMask() & items.COMMINGSOON) != 0) { %>
     <div class=prel><%= dotline %>
      <div class='absleft tfi2 onw' style='color:red;'>Ships in:</div>
      <div class='absright tfi2 onw' style='color:red;'>2-5 Days</div>
     </div>
<%  
    }
    // manufacture warranty any bit up ?
    if((item.getWarrantyMask() & item.MANUFACTURE_WARRANTY) != 0) {
	String warrantyDay = "";
	if((item.getWarrantyMask() & item.MANUFACTURE_W30D) != 0)	warrantyDay = item.W30DAYS;
	else if((item.getWarrantyMask() & item.MANUFACTURE_W45D) != 0)	warrantyDay = item.W45DAYS;
//	else if((item.getWarrantyMask() & item.MANUFACTURE_W90D) != 0)	warrantyDay = item.W90DAYS;
	else if((item.getWarrantyMask() & item.MANUFACTURE_W180D) != 0)	warrantyDay = item.W180DAYS;
	else if((item.getWarrantyMask() & item.MANUFACTURE_W1Y) != 0)	warrantyDay = item.W1YEAR;
	else if((item.getWarrantyMask() & item.MANUFACTURE_W3Y) != 0)	warrantyDay = item.W3YEARS;
	else if((item.getWarrantyMask() & item.MANUFACTURE_W5Y) != 0)	warrantyDay = item.W5YEARS;
%>
     <div class=prel><%= dotline %>
      <div class='absleft tfi2 onw'>Warranty:</div>
      <div class='absright tfi2 onw'><%= String.format("%s<br/>", warrantyDay) %></div>
     </div>
<%
    }
%>
    </div>
<%
    // warranty &&  extended warranty any bit up ?
    if((item.getWarrantyMask() & item.EXTENDED_WARRANTY) != 0) {
	int wpos = 1;
	StringBuilder wbuff = new StringBuilder(300);
        wbuff.append("<div class=curhand onclick=\"location.href='").append(application.getInitParameter("info")).append("ExtWarranty.jsp").append("'\">");
    	wbuff.append("<div class=wty><span style='color:blue;text-decoration:underline;'>Extended Warranty: </span>");
	if((item.getWarrantyMask() & item.WARRANTY_30D) != 0)
	    wbuff.append(selectExtWarranty(wpos++, item.getWarrantyPrice1(), item.getWarrantyPrice2(), item.getWarrantyPrice3(), item.W30DAYS));
	if((item.getWarrantyMask() & item.WARRANTY_60D) != 0)
	    wbuff.append(selectExtWarranty(wpos++, item.getWarrantyPrice1(), item.getWarrantyPrice2(), item.getWarrantyPrice3(), item.W60DAYS));
	if((item.getWarrantyMask() & item.WARRANTY_90D) != 0)
	    wbuff.append(selectExtWarranty(wpos++, item.getWarrantyPrice1(), item.getWarrantyPrice2(), item.getWarrantyPrice3(), item.W90DAYS));
	if((item.getWarrantyMask() & item.WARRANTY_180D) != 0)
	    wbuff.append(selectExtWarranty(wpos++, item.getWarrantyPrice1(), item.getWarrantyPrice2(), item.getWarrantyPrice3(), item.W180DAYS));
	if((item.getWarrantyMask() & item.WARRANTY_1Y) != 0)
	    wbuff.append(selectExtWarranty(wpos++, item.getWarrantyPrice1(), item.getWarrantyPrice2(), item.getWarrantyPrice3(), item.W1YEAR));
	if((item.getWarrantyMask() & item.WARRANTY_3Y) != 0)
	    wbuff.append(selectExtWarranty(wpos++, item.getWarrantyPrice1(), item.getWarrantyPrice2(), item.getWarrantyPrice3(), item.W3YEARS));
	if((item.getWarrantyMask() & item.WARRANTY_5Y) != 0)
	    wbuff.append(selectExtWarranty(wpos++, item.getWarrantyPrice1(), item.getWarrantyPrice2(), item.getWarrantyPrice3(), item.W5YEARS));
	if((item.getWarrantyMask() & item.WARRANTY_LIFE) != 0)
	    wbuff.append(selectExtWarranty(wpos++, item.getWarrantyPrice1(), item.getWarrantyPrice2(), item.getWarrantyPrice3(), item.WLIFETIME));
        wbuff.append("</div></div>");

	out.write(wbuff.toString());
    }
    // Package Include
    if(item.getPackageInclude() != null && item.getPackageInclude().length() != 0) {
	out.write("<div class=tfi5>Package Includes: " + item.getPackageInclude() + "</div>");
    }
    // comment
    if(item.getComments() != null && item.getComments().length() != 0) {
        out.write("<div class=tfi5>Comments: " + item.getComments() + "</div>");
    }
%>
    <div class=tfi5>Product may differ from image shown.</div>
   </td>
  </tr>
 </table>
</fieldset>


<ul id='cv_tb_mn'>
 <li onclick='mk_act(1,<%= itemID %>)'><a class="" id='tb1'>Description</a></li>
<%--
 <li onclick='mk_act(2,0)'><a class= id='tb2'>Second Page</a></li>
 <li onclick='mk_act(3,0)'><a class= id='tb3'>Third Page</a></li>
--%>
</ul>
<div id=cv_cntnt></div>

<div id=out></div>
 
  <div style='text-align:justify;margin:5px 5px;background-color:white;'>
  Warning!
  <font size=-2>Computers and computer circuit boards, as well as other electronic equipment, contain lead, which is a chemical
  known to the State of California to cause cancer or cause birth defects and other reproductive harm.
  Please wash hands after handling circuit boards and other internal components of computers and electronic equipment,
  and avoid inhalation of fumes if heating the solder on the internal components or circuit boards.</font>
 </div>
 </td>
</tr>

<tr height=35>
 <td>

<bottom:show />

 </td>
</tr>

</table>

</body>
<%@ include file="./incl/tracking.incl" %>
</html>
